﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FRW.Common.Configuration;
using System.Drawing;

namespace Money.Interface
{
	public class InterfaceConfiguration : IConfiguration
	{
        public List<CategoriseShortcut> CategoriseShortcuts { get; set; }
        public int Height { get; set; }
        public int Width { get; set; }
        public int PositionX { get; set; }
        public int PositionY { get; set; }
        public bool HideIgnored { get; set; }
        public ColumnWidths ColumnSize { get; set; }
        public List<GridFormatTransactionMatch> TransactionGridFormatRules { get; set; }

        #region Constructors
        public InterfaceConfiguration()
        {
            // TODO do we need this here, dont think we do?
            //CheckConfiguration();
        }
        #endregion

        public void DefaultConfiguration()
        {
            CheckConfiguration();
        }

        public void CheckConfiguration()
        {
            if (CategoriseShortcuts == null)
            {
                CategoriseShortcuts = new List<CategoriseShortcut>();
            }

            if (ColumnSize == null)
            {
                ColumnSize = new ColumnWidths();
            }

            if (TransactionGridFormatRules == null)
            {
                TransactionGridFormatRules = new List<GridFormatTransactionMatch>();
            }

            if (TransactionGridFormatRules.Count == 0)
            {
                // Basic Rules

                GridFormatTransactionMatch matchRule;

                matchRule = new GridFormatTransactionMatch();
                matchRule.MatchRule.MinimumAmount = 1000;
                matchRule.Format.Bold = true;
                TransactionGridFormatRules.Add(matchRule);

                matchRule = new GridFormatTransactionMatch();
                matchRule.MatchRule.MaximumAmount = -1000;
                matchRule.Format.Bold = true;
                TransactionGridFormatRules.Add(matchRule);

                matchRule = new GridFormatTransactionMatch();
                matchRule.MatchRule.CategoryId = Convert.ToInt32(Categories.DefaultCategories.Unknown);
                matchRule.Format.Color = Color.LightCoral;
                matchRule.Format.SelectedColor = Color.Coral;
                TransactionGridFormatRules.Add(matchRule);

                matchRule = new GridFormatTransactionMatch();
                matchRule.MatchRule.CategoryId = Convert.ToInt32(Categories.DefaultCategories.Blank);
                matchRule.Format.Color = Color.LightGray;
                matchRule.Format.SelectedColor = Color.Gray;
                TransactionGridFormatRules.Add(matchRule);

                matchRule = new GridFormatTransactionMatch();
                matchRule.MatchRule.CategoryGroupId = Convert.ToInt32(Categories.DefaultCategories.Luxury);
                matchRule.MatchRule.MaximumAmount = -400;
                matchRule.Format.Color = Color.Orange;
                matchRule.Format.SelectedColor = Color.OrangeRed;
                TransactionGridFormatRules.Add(matchRule);
            }
        }
    }
}
